/******************************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.                       */
/*                                                                            */
/*  NAME      = int sqlserver_token.h                                             */
/*  NOTE      =                                                               */
/*  DATE      = 2014/10/10 by zhengxd                                         */
/******************************************************************************/
#ifndef  SQLSERVER_TOKEN_H_
#define  SQLSERVER_TOKEN_H_

#include "./sqlserver_core.h"

/* token type */
#define MSSQL_TDS_PRELOGIN_TOKEN                    0x00
#define MSSQL_TDS_ALTMETADATA_TOKEN                 0x88
#define MSSQL_TDS_ALTROW_TOKEN                      0xD3
#define MSSQL_TDS_COLMETADATA_TOKEN                 0x81
#define MSSQL_TDS_COLINFO_TOKEN                     0xA5
#define MSSQL_TDS_DONE_TOKEN                        0xFD
#define MSSQL_TDS_DONEPROC_TOKEN                    0xFE
#define MSSQL_TDS_DONEINPROC_TOKEN                  0xFF
#define MSSQL_TDS_ENVCHANGE_TOKEN                   0xE3
#define MSSQL_TDS_ERROR_TOKEN                       0xAA
#define MSSQL_TDS_FEATUREEXTACK_TOKEN               0xAE /* introduced in TDS 7.4 */
#define MSSQL_TDS_INFO_TOKEN                        0xAB
#define MSSQL_TDS_LOGINACK_TOKEN                    0xAD
#define MSSQL_TDS_NBCROW_TOKEN                      0xD2 /* introduced in TDS 7.3 */
#define MSSQL_TDS_OFFSET_TOKEN                      0x78
#define MSSQL_TDS_ORDER_TOKEN                       0xA9
#define MSSQL_TDS_RETURNSTATUS_TOKEN                0x79
#define MSSQL_TDS_RETURNVALUE_TOKEN                 0xAC
#define MSSQL_TDS_ROW_TOKEN                         0xD1
#define MSSQL_TDS_SESSIONSTATE_TOKEN                0xE4 /* introduced in TDS 7.4 */
#define MSSQL_TDS_SSPI_TOKEN                        0xED
#define MSSQL_TDS_TABNAME_TOKEN                     0xA4

int sqlserver_altmetadata_token(Frbyte_Packet *p_st_data
                                , int i_whole_flg
                                , int *p_i_tds_ver
                                , int *p_i_min_tds_ver
                                , int *p_i_max_tds_ver
                                , int *p_i_try_again_flg
                                , Frlist_header *p_lst_header);

int sqlserver_altrow_token(Frbyte_Packet *p_st_data
                           , int i_whole_flg
                           , Frlist_header *p_lst_header);

int sqlserver_colinfo_token(Frbyte_Packet *p_st_data, int i_whole_flg);

int sqlserver_colmetadata_token(Frbyte_Packet *p_st_data
                                , int i_whole_flg
                                , int *p_i_tds_ver
                                , int *p_i_min_tds_ver
                                , int *p_i_max_tds_ver
                                , int *p_i_try_again_flg
                                , Frlist_header *p_lst_header);

int sqlserver_row_token(Frbyte_Packet *p_st_data
                        , int i_whole_flg
                        , Frlist_header *p_lst_header);

int sqlserver_done_token(Frbyte_Packet *p_st_data
                         , int i_whole_flg
                         , int *p_i_tds_ver
                         , int *p_i_min_tds_ver
                         , int *p_i_max_tds_ver
                         , int *p_i_try_again_flg
                         , int *p_i_normal_flg
                         , unsigned long long *p_ull_effect_rows);

int sqlserver_doneinproc_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , int *p_i_tds_ver
                               , int *p_i_min_tds_ver
                               , int *p_i_max_tds_ver
                               , int *p_i_try_again_flg
                               , unsigned long long *p_ull_effect_rows);

int sqlserver_doneproc_token(Frbyte_Packet *p_st_data
                             , int i_whole_flg
                             , int *p_i_tds_ver
                             , int *p_i_min_tds_ver
                             , int *p_i_max_tds_ver
                             , int *p_i_try_again_flg
                             , int *p_i_normal_flg
                             , unsigned long long *p_ull_effect_rows);

int sqlserver_envchange_token(Frbyte_Packet *p_st_data
                              , int i_whole_flg
                              , int *p_i_tds_ver
                              , int *p_i_min_tds_ver
                              , int *p_i_max_tds_ver
                              , char **pp_charset);

int sqlserver_error_token(Frbyte_Packet *p_st_data
                          , int i_whole_flg
                          , int *p_i_tds_ver
                          , int *p_i_min_tds_ver
                          , int *p_i_max_tds_ver
                          , long long *p_ll_error_num
                          , char **pp_error_msg);

int sqlserver_featureextack_token(Frbyte_Packet *p_st_data, int i_whole_flg);

int sqlserver_info_token(Frbyte_Packet *p_st_data
                         , int i_whole_flg
                         , int *p_i_tds_ver
                         , int *p_i_min_tds_ver
                         , int *p_i_max_tds_ver);

int sqlserver_loginack_token(Frbyte_Packet *p_st_data
                             , int i_whole_flg
                             , int *p_i_ser_tds_ver);

int sqlserver_nbcrow_token(Frbyte_Packet *p_st_data
                           , int i_whole_flg
                           , int *p_i_tds_ver
                           , int *p_i_min_tds_ver
                           , int *p_i_max_tds_ver
                           , Frlist_header *p_lst_colmetadata);

int sqlserver_offset_token(Frbyte_Packet *p_st_data
                           , int i_whole_flg
                           , int *p_i_tds_ver
                           , int *p_i_max_tds_ver
                           , int *p_i_min_tds_ver);

int sqlserver_order_token(Frbyte_Packet *p_st_data, int i_whole_flg);

int sqlserver_returnstatus_token(Frbyte_Packet *p_st_data, int i_whole_flg);

int sqlserver_returnvalue_token(Frbyte_Packet *p_st_data
                                , int i_whole_flg
                                , int *p_i_tds_ver
                                , int *p_i_min_tds_ver
                                , int *p_i_max_tds_ver
                                , int *p_i_try_again_flg
                                , unsigned long long *p_ull_uid);

int sqlserver_sessionstate_token(Frbyte_Packet *p_st_data, int i_whole_flg);

int sqlserver_sspi_token(Frbyte_Packet *p_st_data, int i_whole_flg);

int sqlserver_tabname_token(Frbyte_Packet *p_st_data
                            , int i_whole_flg
                            , int *p_i_tds_ver
                            , int *p_i_max_tds_ver
                            , int *p_i_min_tds_ver);

int sqlserver_tvp_row_token(Frbyte_Packet *p_st_data, int i_whole_flg);

#endif


